1 REM MC-10 TREK REV 1.0
2 CLS:GOSUB880:G=16393:PL=480:GOTO10
3 K=K+(N<X2)+(N<Y2)+(N<.5)+(N<.25)+(N<.15):D=D-K:RETURN
5 FORN=1TOLEN(A$):POKEL+N,ASC(MID$(A$,N,1)):NEXT:RETURN
6 FND=SQR((I(I)-U)^2+(J(I)-V)^2):RETURN
7 FORJ=0TO1200:NEXT
8 PRINT@PL,"                         ";:PRINT@PL,"";:RETURN
10 DIMD(5),I(7),J(7),K(7),S(7,7),Q(7,7),D$(5),L(5),C(4)
11 FORI=1TO24:BL$=BL$+CHR$(128):CL$=CL$+" ":NEXT
15 L(0)=376:L(1)=224:L(2)=397:L(3)=312:L(4)=248:L(5)=440
20 C(0)=39:C(1)=43:C(2)=41:C(3)=35:C(4)=42:D$(0)="ENGINES"
25 D$(1)="SR SENSORS":D$(2)="LR SENSORS":D$(3)="PHASERS"
30 D$(4)="TORPEDOS":D$(5)="RECORDS":GOSUB175:Q=X:R=Y:X=8:Y=1:X1=.25
35 Y1=7.55:X2=7:Y2=2.5:D=0
40 T=3431:O=T+31.5:E=4000:P=10:FORI=0TO7:CLS(RND(8)):PRINT"STAND BY"
45 FORJ=0TO7:K=0:N=RND(100):N=N*.01:IFN<X1 THENN=N*64:K=(N<Y1)-Y:GOSUB3
50 B=(RND(100)>96):BA=BA-B:Q(I,J)=K*100+B*10-RND(8):NEXTJ,I
55 IFD>30THENO=T+D
60 IFBA>0THEN70
65 GOSUB175:Q(X,Y)=Q(X,Y)-10:BA=1
70 PRINT"ARE YOU--":PRINT:PRINT"1-A NOVICE":PRINT:PRINT"2-AN EXPERT";
71 A$=INKEY$:X=RND(100):IFA$=""THEN71
75 IFVAL(A$)<>2THENT=T-.5*D
80 GOSUB725
85 F=0:A=0:IFQ<0 ORQ>7 ORR>7 ORR<0 THENN=0:S=0:K=0:GOTO95
90 N=ABS(Q(Q,R)):Q(Q,R)=N:S=N-INT(N/10)*10:K=INT(N/100)
95 B=INT(N/10-K*10):GOSUB175:U=X:V=Y
100 FORI=0TO7:FORJ=0TO7:S(I,J)=1:NEXTJ,I:S(U,V)=2
105 FORI=0TO7:K(I)=0:X=8:IFI<K THENGOSUB180:S(X,Y)=3:K(I)=400
110 I(I)=X:J(I)=Y:NEXT:I=S:IFB>0THENGOSUB180:S(X,Y)=4
115 IFI>0THENGOSUB180:S(X,Y)=5:I=I-1:GOTO115
120 GOSUB775:GOSUB125:IFNOTZ THENGOSUB635
121 GOTO320
122 A$=STR$(O-T):A$=LEFT$(A$,7):PRINT@120,A$:RETURN
125 GOSUB270:IFA=0ORK>0 THENGOSUB190
130 I=1:IFD(I)<=0THEN140
135 FORI=0TO7:FORJ=0TO7:POKEG+J*2+32*I,169:NEXTJ,I:GOTO145
140 FORI=0TO7:FORJ=0TO7:POKEG+J*2+32*I,C(S(I,J)-1):NEXTJ,I
145 PRINT@56,STR$(INT(T))" ";:GOSUB122
150 PRINT@32,"      ";:PRINT@32,C$;
155 PRINT@184,STR$(INT(E));" ";:IFZ THENRETURN
160 PRINT@128,STR$(Q+1);"-";STR$(R+1);:PRINT@504,STR$(D);" ";
165 IFD(4)=0THENPRINT@248,STR$(P);"   ";
170 RETURN
175 X=RND(8)-1:Y=RND(8)-1:RETURN
180 GOSUB175:IFS(X,Y)>1THEN180
185 RETURN
190 IFK<1ANDNOTZ THENRETURN
195 IFK>0ANDZ THEN225
200 IFK<1ANDZ THENFORJ=0TO200:NEXT
205 GOSUB270:GOSUB150:PRINT@192,"BATTLE ";:PRINT@224,"COMPUTER";:FORI=256TO448STEP32
207 PRINT@I,CL$;
208 NEXT
210 IFK<1 ORF THENZ=0:A=2:GOSUB740:GOSUB635:GOSUB731:GOSUB775:GOSUB801:RETURN
220 Z=-1
225 IF C$="DOCKED" THENPRINT@PL,"SHIELDED BY STARBASE";:RETURN
230 FORI=0TO7:IFK(I)<=0THENNEXT:RETURN
235 H=K(I)*.42*RND(100)/100:GOSUB6:K(I)=K(I)-H:H=H/(FND^.1):E=E-H:J=G+V*2+32*U
245 IFA<>6THENFORN=0TO25:POKEJ,159:POKEJ,43:NEXT:GOSUB255
248 IFY=99THENRETURN
250 NEXT:RETURN
255 L=I*32+256:IFK(I)<0 THENPRINT@L," ***KLINGON DESTROYED***";:RETURN
260 A$=STR$(H):PRINT@L,LEFT$(A$,7);:A$=STR$(K(I)):PRINT@L+11,LEFT$(A$,7);
265 RETURN
270 FORI=U-1TOU+1:FORJ=V-1TOV+1:IFI<0ORI>7ORJ<0ORJ>7THEN280
275 IFS(I,J)=4THENC$="DOCKED":E=4000:P=10:GOSUB295:RETURN
280 NEXTJ,I:IFK>0THENC$="RED":RETURN
285 IFE<400THENC$="YELLOW":RETURN
290 C$="GREEN":RETURN
295 IFD(1)THENDS=1
296 IFD(2)THENDL=1
297 DF=1:FORN=0TO5:D(N)=0:NEXT:RETURN
300 PRINT@PL,D$(I);" DAMAGED";:GOSUB7:IFNOTSFANDI<>4THENRETURN
305 A$=STR$(D(I))+"YRS"
310 L=L(I):PRINT@L,A$;:RETURN
320 IFDF THENGOSUB775:DF=0
321 IFDS ORD(1) THENGOSUB130:DS=0
322 GOSUB8:IFDLANDNOTZ THENGOSUB635:DL=0
325 GOSUB8:PRINT@PL,"COMMAND?";:GOSUB805:A=J:IFA<1ORA>6THEN325
326 ONA GOTO350,325,335,565,340,660
335 F=NOTF:GOSUB205:GOTO320
340 I=4:F=0:GOSUB8:IFD(I)>0THENGOSUB300:GOTO320
345 N=15:IFP<1THENPRINT@PL,"TORPEDO RACKS - EMPTY -";:GOSUB7:GOTO320
350 GOSUB8:PRINT@PL,"COURSE (1-8.9)?";:GOSUB805:C=J:IFC<1THEN320
355 IFC>9THEN350
360 IFA<>5THEN370
365 P=P-1:PRINT@PL,"TRACKING PHOTON TORPEDO";:GOTO445
370 GOSUB8:PRINT@PL,"WARP (0-12)?";:GOSUB805:W=J:IFW<=0ORW>12THEN350
375 GOSUB8:IFW<=.5ORD(0)<=0THEN385
380 PRINT@PL,"MAXIMUM WARP IS .5!";:GOSUB7:GOTO370
385 IFK>0THENF=0
390 GOSUB190
395 IFRND(100)>25ORE>RND(500)+2500ORO-T<5THEN430
400 X=RND(6)-1:IFRND(10)>5THEN415
405 D(X)=D(X)+RND(4):PRINT@266,"**ION STORM**";:DS=1
406 IFX=2THENDL=1
410 GOSUB7:FORI=0TO12:POKE16650+I,96:NEXT:I=X:GOSUB300:D(X)=D(X)+1:GOTO430
415 FOR I=X TO 5:IF D(I)>0 THEN 425
420 NEXT:FORI=0TOX:IFD(I)<=0THENNEXT:GOTO430
425 D(I)=.5
430 FORI=0TO5:IFD(I)=0THEN440
435 D(I)=D(I)-1:DF=1:IFD(I)>0THEN440
436 IFD(I)<=0THEND(I)=0:GOSUB7:PRINT@PL,D$(I);" ARE FIXED";
437 IFI=1ANDD(I)=0THENDS=1
438 IFI=2ANDD(I)=0THENDL=1:GOSUB801
440 NEXT:N=INT(W*8):E=E-N-N+.5:S(U,V)=1:X2=8:Y2=8
445 Y1=U+.5:X1=V+.5:Y=(C-1)*.785398:X=COS(Y):Y=-SIN(Y)
450 IFA=1 THENIFD(1)<=0 THENIFV>=0THENIFV<8THENIFU>=0THENIFU<8THENPOKEG+V*2+U*32,39
455 FORI=1TON:IFX2>-1 ANDX2<8 ANDY2>-1 ANDY2<8 THENIFD(1)<=0THENPOKEG+X2*2+32*INT(Y2),39
456 Y1=Y1+Y:X1=X1+X:Y2=INT(Y1)
460 X2=INT(X1):IFX2<0ORX2>7ORY2<0ORY2>7THEN550
465 H=G+X2*2+32*Y2:C=43:IFA=5THENC=0
470 IFS(Y2,X2)<>1 THEN475
471 IFD(1)<=0 THENPOKEH,C
472 FORJ=0TO50:NEXTJ,I:T=T+1*.1:GOTO530
475 IFA=5THENFORJ=192TO218:POKEH,J:NEXT:POKEH,39
480 GOSUB8:IFA=1THENPRINT@PL,"BLOCKED BY ";
485 ON S(Y2,X2)-3GOTO520,510
490 IFA=1THENPRINT"KLINGON";:GOTO525
495 FORI=0TO7:IFY2<>I(I)THEN505
500 IFX2=J(I)THENK(I)=-5:GOSUB255
505 NEXT:K=K-1:D=D-1:GOTO540
510 PRINT"STAR";:IFA=5THENS=S-1:GOTO535
515 GOTO525
520 PRINT"STARBASE";:IFA=5THENB=0:BA=BA-1:GOTO535
525 Y2=INT(Y1-Y):X2=INT(X1-X):IFD(1)<=0 THENPOKEG+X2*2+32*Y2,43
530 U=Y2:V=X2:S(U,V)=2:GOTO545
535 PRINT" DESTROYED!";
540 S(Y2,X2)=1:Q(Q,R)=K*100+B*10+S:IFD(1)<=0 THENPOKEG+V*2+32*U,43
541 IFD<1THEN705
545 GOSUB190:GOSUB270:GOSUB150:GOSUB165:GOTO320
550 IFA=5THENPRINT@PL,"<<<<<<< MISSED >>>>>>>>";:GOSUB7:GOTO545
555 T=T+1:Q=INT(Q+W*Y+(U+.5)/8):R=INT(R+W*X+(V+.5)/8)
560 Q=Q-(Q<0)+(Q>7):R=R-(R<0)+(R>7):GOTO85
565 I=3:F=0:IFD(I)>0THENGOSUB300:GOTO320
570 PRINT@PL,"UNITS TO FIRE?";:GOSUB805:X=J:IFX=0THEN320
575 IFX>E THENPRINT@PL,"ONLY HAVE ";E;" UNITS";:GOSUB7:GOTO570
580 E=E-X:GOSUB155:Y=K:FORI=0TO7
590 IFK(I)<=0THEN625
595 GOSUB6:H=X/(Y*(FND^.4)):K(I)=K(I)-H
600 J=G+J(I)*2+32*I(I):IFD(1)=0THENFORN=0TO20:POKEJ,159:POKEJ,41:NEXT
605 IFK(I)>0THEN615
610 FORN=192TO218:POKEG+J(I)*2+32*I(I),N:NEXTN:POKEG+J(I)*2+32*I(I),39
615 GOSUB255:IFK(I)>0THEN625
620 K=K-1:D=D-1:S(I(I),J(I))=1:Q(Q,R)=Q(Q,R)-100
625 NEXT:IFD<1THEN705
630 FORJ=0TO500:NEXTJ:GOTO545
635 I=2:L=16682:IFD(I)<=0THEN645
640 FORI=0TO2:FORJ=1TO11:POKE16682+J+32*I,169:NEXTJ,I:GOSUB305:RETURN
645 FORI=Q-1TOQ+1:FORJ=R-1TOR+1
650 IFI<0ORI>7ORJ<0ORJ>7THENA$="***":GOTO700
655 Q(I,J)=ABS(Q(I,J)):GOTO680
660 I=5:IFD(I)>0THENGOSUB300:A=3:GOTO320
665 CLS:PRINTTAB(4)"CUMULATIVE GALACTIC MAP"
670 PRINT:PRINT" FOR QUADRANT";TAB(25)"TIME":PRINTQ+1"-"R+1
675 FORI=0TO7:FORJ=0TO7:IFQ(I,J)<0 THENA$="<->":GOTO685
680 A$=STR$(Q(I,J)):A$="00"+MID$(A$,2):A$=RIGHT$(A$,3):IFA<6THEN700
685 PRINTA$;:IFJ<7THENPRINT" ";
690 NEXTJ:PRINT:NEXTI:PRINT:PRINTBA;"STARBASES":PRINT"READY?":GOSUB805:CLS:A=2
695 GOSUB725:Z=0:F=0:GOTO120
700 GOSUB5:L=L+4:NEXTJ:L=L+20:NEXT:RETURN
705 PRINT@PL,"-YOU WIN-":END
720 CLS(0)
725 CLS:GOSUB750:PRINT@24,"STARDATE";:PRINT@88,"TIME":PRINT@152,"ENERGY":PRINT@216,"TORPEDOS";
730 PRINT@280,"PHASERS":PRINT@344,"ENGINES":PRINT@408,"RECORDS":PRINT@472,"KLINGONS";:GOSUB800
731 PRINT@192,"SENSORS  ";:PRINT@224,"         ";
732 PRINT@0,"CONDITION";
733 PRINT@96,"QUADRANT ";
740 PRINT@PL,"YOU HAVE";BA;"STARBASES";:RETURN
750 A$="        ":FORI=24TO504STEP32:PRINT@I,A$;:NEXT:A$=A$+" ":PRINT@32,A$;:PRINT@128,A$;
755 RETURN
775 IFK>0 ANDNOTSF THEN795
780 FORI=0TO5:IFD(I)<=0THENA$="READY":GOSUB310:GOTO790
785 GOSUB305
790 NEXTI
795 GOSUB165:RETURN
800 PQ=16393:FORI=1TO13STEP2:FORJ=0TO7:POKEPQ+I+32*J,32:NEXTJ,I
801 PQ=16686:FORI=0TO4STEP4:FORJ=0TO2:POKEPQ+I+32*J,32:NEXTJ,I:RETURN
805 B$=""
810 IFT>O THENGOTO865
815 IFE<1THEN870
820 IFZ AND RND(100)>96 THENGOSUB861
825 M=M+1:IFM>80THENT=T+.061:M=0:IFE<5000 THENGOSUB122
835 A$=INKEY$:IFA$<>""THENIFASC(A$)=8THENJ=0:GOSUB8:RETURN
840 IFA$<>""THENIFASC(A$)=13THENGOSUB8:GOTO860
845 B$=B$+A$:IFA$<>"" THENPRINT@PL+18,B$;
855 GOTO820
860 J=VAL(B$):RETURN
861 IFC$="DOCKED"THENRETURN
862 I=RND(6)-1:IFK(I)<=0THENRETURN
863 Y=99:GOSUB235:IFA<>6THENGOSUB155
864 RETURN
865 A$="        ":FORI=0TO20:PRINT@120,A$;:GOSUB879:PRINT@120,STR$(O-T);:GOSUB879:NEXT:GOTO875
870 FORI=0TO20:A$="        ":PRINT@184,A$;:GOSUB879:A$=STR$(INT(E)):PRINT@184,A$;:GOSUB879:NEXT
875 GOSUB8:PRINTTAB(6)"-YOU LOSE-":END
879 FORJ=0TO50:NEXT:RETURN
880 PRINT@256,"MODIFIED BY JIM GERRIE";
885 RETURN
